home *** CD-ROM | disk | FTP | other *** search
- // ******************************************************************
- //
- // helloapp.cpp
- //
- // Implemented classes:
- // CHelloWinApp
- // CHelloMainWnd
- //
- // Remarks
- // CHelloWinApp is not generated by ClassWizard
- //
- // Author : Nils Behncke
- // POET Software GmbH, August 1993
- //
- // ******************************************************************
-
- #include <stdafx.h> // header to MFC
-
-
-
- #include <helloapp.h> // header to this file
- #include <aboutdlg.h> // header to aboutdialog
- #include <persdlg.h> // header to persondialog
- #include <progdlg.h> // header to programmerdialog
- #include <persqry.h> // header to personquerydialog
- #include <progqry.h> // header to programmerquerydialog
-
-
- CHelloWinApp NEAR theApp; // instance of application
-
-
-
- /////////////////////////////////////////////////////////////////////////////////
- // CHelloMainWnd
-
-
- CHelloMainWnd::CHelloMainWnd ()
- {
- Create( NULL, "Hello POET",WS_OVERLAPPEDWINDOW,rectDefault, // create mainwindow with menu
- NULL, MAKEINTRESOURCE (IDR_WINHELLOMENU) );
-
- }
-
-
- BEGIN_MESSAGE_MAP(CHelloMainWnd, CFrameWnd)
- //{{AFX_MSG_MAP(CHelloMainWnd)
- ON_COMMAND(IDM_ABOUT, OnAbout)
- ON_COMMAND(IDM_PERS_EDIT, OnPersEdit)
- ON_COMMAND(IDM_PROG_EDIT, OnProgEdit)
- ON_COMMAND(IDM_EXIT, OnExit)
- ON_COMMAND(IDM_PERS_QUERY, OnPersQuery)
- ON_COMMAND(IDM_PROG_QUERY, OnProgQuery)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CHelloMainWnd message handlers
-
-
- void CHelloMainWnd::OnAbout()
- {
- int nResult;
-
- CAboutDlg aboutdlg (this);
- nResult = aboutdlg.DoModal (); // start dialog
- aboutdlg.EndDialog (nResult);
- }
-
- void CHelloMainWnd::OnPersEdit()
- {
- int nResult;
-
- CEditPersDlg editpersdlg (this);
- nResult = editpersdlg.DoModal (); // start dialog
- editpersdlg.EndDialog (nResult);
- }
-
- void CHelloMainWnd::OnProgEdit()
- {
- int nResult;
-
- CEditProgDlg editprogdlg (this);
- nResult = editprogdlg.DoModal (); // start dialog
- editprogdlg.EndDialog (nResult);
- }
-
- void CHelloMainWnd::OnExit()
- {
- if (MessageBox ("Terminate Program","Hello POET",MB_YESNO)==IDYES)
- {
- DestroyWindow ();
- };
- }
-
- void CHelloMainWnd::OnPersQuery()
- {
- int nResult;
-
- CPersQueryDlg persquery (this);
- nResult = persquery.DoModal (); // start dialog
- persquery.EndDialog (nResult);
- }
-
- void CHelloMainWnd::OnProgQuery()
- {
- int nResult;
-
- CProgQueryDlg progquery (this);
- nResult = progquery.DoModal (); // start dialog
- progquery.EndDialog (nResult);
- }
-
-
-
- // ******************************************************************
- //
- // Implementation of the class CHelloWinApp
- //
- // ******************************************************************
-
- CHelloWinApp::CHelloWinApp ()
- {
- }
-
-
- CHelloWinApp::~CHelloWinApp ()
- {
- if (oa->Close()!=0) // Close database "base"
- ErrorExit ("Cannot close base");
-
- if (oa->DisConnect()!=0) // Disconnect from server
- ErrorExit ("Can't disconnect the program from the server");
-
- delete oa;
- }
-
-
-
- BOOL CHelloWinApp::InitInstance ()
- {
- m_pMainWnd = new CHelloMainWnd (); // create mainwindow
- m_pMainWnd->ShowWindow (m_nCmdShow); // show it
- m_pMainWnd->UpdateWindow ();
-
- int err = 0;
-
- oa = new PtBase (); // Instance for POET administration
-
- if ((err=oa->Connect ("LOCAL"))!=0) // Connect to server LOCAL
- ErrorExit ("Can't connect to server");
-
- if ((err=oa->Open ("base"))!=0) // Open database "base"
- ErrorExit ("Cannot open base");
-
-
- return TRUE;
- }
-
-
- void CHelloWinApp::ErrorExit (char *error)
- {
- m_pMainWnd->MessageBox (" Error : " + CString(error) + " ","Abort program",MB_OK);
- m_pMainWnd->DestroyWindow ();
- };